package cn.itsource.service.impl;

import cn.itsource.feign.LogisticFeignClient;
import cn.itsource.mapper.OrderMapper;
import cn.itsource.pojo.Logistic;
import cn.itsource.pojo.Order;
import cn.itsource.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private LogisticFeignClient logisticFeignClient;

    @Override
    public List<Order> queryAll() {
        return orderMapper.loadAll();
    }

    @Override
    public Order queryById(Integer id) {
        return orderMapper.loadById(id);
    }

    @Override
    public void add(Order order) {
        orderMapper.add(order);
    }

    @Override
    public void update(Order order) {
        orderMapper.update(order);
    }

    @Override
    public void queryAllInfo(Integer id) {
//        List<Object> allInfo = new ArrayList<>();
//        Order order = orderMapper.loadById(id);
//        String orderStatus = order.getOrderStatus();
//        if (orderStatus.equals("已发货")||orderStatus.equals("已收货")){
//            allInfo.add(order);
//            Logistic logistic = logisticFeignClient.queryBySn(id);
//            allInfo.add(logistic);
//        }else {
//            allInfo.add(order);
//        }
    }
}
